'use strict';
const axios = require('axios');
const url = "https://m-api.yzbtdiy.com/personalized"
const db = uniCloud.database();
exports.main = async (event, context) => {
	// //event为客户端上传的参数
	// console.log('event : ', event)

	// //返回数据给客户端
	// return event
	let playList = await axios.get(url).then((res) => {
		return res.data.result
	}).catch((err) => {
		console.log(err);
	})
	for (let i = 0; i < playList.length; i++) {
		db.collection("playList").add({
			data: {
				...playList[i],
				createTime: db.date
			}
		}).then((res)=>{console.log("add data success")}).catch((err)=>{
			console.log("add data failed")
		})
	}
};
